﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CuttingStock
{
    public class ProductRequest
    {
        public static Int32[,] productTypes = new Int32[,] {
            { 2, 3, 0, 0, 1 },
            { 1, 1, 4, 1, 1 },
            { 0, 0, 0, 2, 3 },
            { 2, 1, 2, 0, 1 }
        };

        public static Int32[] productReqs = new Int32[] {
            300, 450, 330, 410
        };

        /// <summary>
        /// need to be updated
        /// </summary>
        public static Int32[] featureReqs = null;

        /// <summary>
        /// all the static fields should be set before calling this funtion
        /// </summary>
        /// <returns></returns>
        public static Int32[] GenerateRequests()
        {
            var numProduct = productReqs.Count();
            var numFeature = productTypes.GetLength(1);

            if (numProduct != productTypes.GetLength(0))
                throw new ArgumentException("product number should equal to the number in product types");

            featureReqs = new Int32[numFeature];

            for (var i = 0; i < numProduct; ++i)
            {
                for (var j = 0; j < numFeature; ++j)
                {
                    featureReqs[j] += productTypes[i, j] * productReqs[i];
                }
            }

            return featureReqs;
        }
    }
}
